import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

/**
 * @author:cai
 * @date:2022-05-17-10:18
 */
public class read {

        public static void File_read() throws FileNotFoundException {
            File path = new File("H://date/");
            String[] list = path.list();

            for(String itemName : list){
                System.out.println(itemName);
            }
            System.out.println("请输入你要读取的日记全名：");
            Scanner sc1=new Scanner(System.in);
            String src= sc1.next();
            String fileName = "H://date/"+src;
            System.out.println("================================");
            try (Scanner sc = new Scanner(new FileReader(fileName))) {
                while (sc.hasNextLine()) {  //按行读取字符串
                    String line = sc.nextLine();
                    System.out.println(line);
                }
            }
            System.out.println("===========输出完成！=============");
            System.out.println("已经返回菜单！1，写日记    2.读取日记");
        }

}
